<style>
.fui-header:after {
	height: 0;
	border-bottom: 0 solid #D9D9D9;
}
.search-input input {
	border-radius: 1rem;
	background-color:#f2f2f2;
	border: 0 solid #ddd;
}
</style>
<div ng-show="pagedata.isshowarea ==1">
<div class="fui-page fui-page-current page-goods-list" style="background:#fff">
	<div class="fui-header" style="background:none">
		<div class="fui-header-left">
			<a class="back" style="color:#fff" href="javascript:" ng-click="pagedata.isshowarea=0;pagedata.getlist()"></a>
		</div>
		<div class="title bold" style="font-size:1rem;">定位门店地址</div>
		<div class="fui-header-right" style="padding-right:0.5rem;">
			<i class="icon jinyunicon icon-fenxiang2" onclick="$('#showsharecover').modal();" style="font-size: 1rem;margin-right:10px"></i>
			<i class="icon jinyunicon icon-liaotian" ng-click="access_json('jy_weishop/member.index/')" style="font-size: 1rem;"></i>
		</div>
	</div>
<div class="fui-content" style="margin-top:2.3rem;background:#fff">
		<div class="fui-cell-group">
			<div class="fui-cell">
				<div class="fui-cell-label">
					<span style="font-size:0.75rem">{{pagedata.pcd.city || '全国'}}</span>
				</div>
				<div ng-click="pagedata.choose_location()" class="fui-cell-info search-input">
					<i id="searchsub" class="fa fa-search"  ng-click="pagedata.getlist()"></i>
					<input type="search" placeholder="当前位置：{{pagedata.pcd.street}}" ng-change="pagedata.getlist(true);" class="search" ng-model="pagedata.addressinfo.title"/>
				</div>
			</div>
	    </div>
		<div class="weui_cells" style="margin-top:0">
				<a class="weui_cell" href="javascript:;">
					<div class="weui_cell_bd weui_cell_primary">
						<span>{{pagedata.pcd.street || '还未定位街道'}}</span>
					</div>
					<div class="weui_cell_ft red" ng-click="pagedata.uplocation(1);">
						<i class="icon icon-ditu"></i>
						重新定位
					</div>
				</a>
		</div>
		<div ng-if="pagedata.history.length>0" class="weui_cells" style="margin:2%">
			<div class="weui_cell" id="r-result" ng-repeat="item in pagedata.history">
				<div class="weui_cell_hd icon jinyunicon icon-ditu"></div>
				<div class="weui_cell_bd weui_cell_primary"  ng-click="">
					<span style="float:left;width:100%;">{{item.address}}</span>
					<span style="float:left;font-size:0.55rem;color:#646464">{{item.pcd}}</span>
				</div>
			</div>
		</div>
		<div class="weui_cells weui_cells_access" style="margin-top:0.2rem">
				<a class="weui_cell" href="javascript:;">
					<div class="weui_cell_hd weui_cell_primary" style="padding:0.6rem 0">
						<span>当前定位/选择地区：{{pagedata.pcd.city || '广州市'}}</span>
					</div>
					<div class="weui_cell_ft" ng-click="toogle(post,'show')">
						选择县区
					</div>
				</a>
				<div class="row margin0" ng-show="post.show">
						<div class="jy-3" ng-repeat="value in pagedata.province[pagedata.pcd.province][pagedata.pcd.city]">
							<div class="yuyue-duan" style="width:auto" ng-click="selectarea(pagedata.pcd.province,pagedata.pcd.city,value);pagedata.showarea = 0;">
									<div>{{value}}</div>
									<div class="clear"></div>
							</div>
						</div>
				</div>
			</div>
			<div class="weui_cells_title">热门地区</div>
			<div class="weui_cells">
				<div class="row margin0">
						<div class="jy-3">
							<div class="yuyue-duan" style="width:auto" ng-click="selectarea('','','',1);pagedata.showarea = 0;">
									<div>全国</div>
									<div class="clear"></div>
							</div>
						</div>
						<div class="jy-3">
							<div class="yuyue-duan" style="width:auto" ng-click="selectarea('广东省','深圳市','');pagedata.showarea = 0;">
									<div>深圳市</div>
									<div class="clear"></div>
							</div>
						</div>
						<div class="jy-3">
							<div class="yuyue-duan" style="width:auto" ng-click="selectarea('上海市','上海市','');pagedata.showarea = 0;">
									<div>上海市</div>
									<div class="clear"></div>
							</div>
						</div>
						<div class="jy-3">
							<div class="yuyue-duan" style="width:auto" ng-click="selectarea('广东省','东莞市','');pagedata.showarea = 0;">
									<div>东莞市</div>
									<div class="clear"></div>
							</div>
						</div>
						<div class="jy-3">
							<div class="yuyue-duan" style="width:auto" ng-click="selectarea('北京市','北京市','');pagedata.showarea = 0;">
									<div>北京市</div>
									<div class="clear"></div>
							</div>
						</div>
						<div class="jy-3">
							<div class="yuyue-duan" style="width:auto" ng-click="selectarea('江苏省','南京市','');pagedata.showarea = 0;">
									<div>南京市</div>
									<div class="clear"></div>
							</div>
						</div>
						<div class="jy-3">
							<div class="yuyue-duan" style="width:auto" ng-click="selectarea('江苏省','杭州市','');pagedata.showarea = 0;">
									<div>杭州市</div>
									<div class="clear"></div>
							</div>
						</div>
				</div>
			</div>
			<div ng-repeat="(value,data) in pagedata.province">
				<div class="weui_cells_title">{{value}}</div>
				<div class="weui_cells">
					<div class="row margin0">
						<div class="jy-3" ng-repeat="(city,data) in pagedata.province[value]">
								<div class="yuyue-duan" style="width:auto" ng-click="selectarea(value,city,'');pagedata.showarea = 0;">
										<div>{{city}}</div>
										<div class="clear"></div>
								</div>
						</div>
					</div>
				</div>
		    </div>
</div>
</div>
<script>
scope.pagedata.addressinfo={}
scope.pagedata.setting=scope.pagedata.setting?scope.pagedata.setting:{}
scope.pagedata.uplocation=function(isup){
	// 百度地图API功能
	window.scope.location(function(re){
		console.log(re)
		var lat_lng = re.lat_lng;
		scope.pagedata.params.showtype=scope.pagedata.showtype;
		scope.pagedata.params.lat=lat_lng.lat;
		scope.pagedata.params.lng=lat_lng.lng;
		scope.pagedata.pcd=re.addressComponents;
		scope.pagedata.pcd.street=scope.pagedata.pcd.street_recommend?scope.pagedata.pcd.street_recommend:scope.pagedata.pcd.street;
		scope.pagedata.getlist();	
		if(isup){
				scope.message('定位成功');
				scope.$evalAsync();
		}	
	},scope.pagedata.setting.no_location,'',isup);
}
scope.pagedata.getprovince=function(){
	scope.get('jy_weishop/get_data/getprovince/',function(res){
		console.log(res)
		scope.pagedata.province=res.province
		scope.$evalAsync();
	});
}
scope.pagedata.getprovince()
scope.pagedata.choose_location=function(obj,field,type){
		scope.modal_func(function(res){
			if(type && res[type]){
				var ret=res[type];
			}else{
				var ret=res;
			}
			console.log(res);
			scope.pagedata.params.lat=res.lat_lng.lat;
			scope.pagedata.params.lng=res.lat_lng.lng;
			scope.pagedata.pcd.street=res.title
			scope.pagedata.getlist();
			scope.$evalAsync();
		},'','core/tools.choose_location/');
}
scope.selectarea = function(province,city,district,nocity){
	scope.$evalAsync(function(){
		scope.pagedata.pcd.province = province;
		scope.pagedata.pcd.city = city;
		scope.pagedata.pcd.district = district;
		scope.pagedata.pcd.nocity = nocity?nocity:'';
		scope.pagedata.showcity=0;
		scope.pagedata.isshowarea =0;
		scope.pagedata.getlist();
	});
}
</script>
</div>